function [filename_out, variable_name] = save( session, name, varargin ) 
%SAVE �˴���ʾ�йش˺�����ժҪ
%   �˴���ʾ��ϸ˵��
    p=inputParser;
    p.addRequired('name', @ischar);
    p.addParameter('isSaveBuffer', false, @islogical);
    p.parse(name, varargin{:});
    
    timestamp = datestr( session.start_time,  'yyyymmdd_hhMMss' );
    filename_out = [timestamp '_' p.Results.name, ...
                              '_CORE' session.repository.core.revision(1:5) ...
                              '_APP' session.repository.app.revision(1:5) ...
                              '.mat'];
    variable_name = ['session_' timestamp];
    if p.Results.isSaveBuffer
        eval([variable_name '.measurement_buffer= session.measurement_buffer;']);
    end
    eval([variable_name '.measurement_data= session.measurement_data;']);
    eval([variable_name '.repository= session.repository;']);
    eval([variable_name '.start_time= session.start_time;']);
    
    d = Constant.PathDelimiter;
    if ispc
        save([Constant.AutoMeasurementDataPath d filename_out], variable_name);
    elseif ismac
        save([Constant.AutoMeasurementDataPath d filename_out], variable_name);
    end
    
    L=log4m.getLogger;
    L.info('MeasurementSession::save', sprintf('Data saved in file %s.', filename_out));
end
